/************************************************************
   Copyright 2008 Abhinav Pobbati

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*************************************************************/

#pragma once
#include "Havok4Xna/Physics/Collide/HkpCollide.h"
#include "Havok4Xna/Physics/Collide/Agent/HkpAgent.h"
#include "Havok4Xna/Physics/Collide/Shape/HkpShape.h"

#pragma unmanaged
#include <Physics/Collide/Filter/hkpCollidableCollidableFilter.h>
#include <Physics/Collide/Filter/hkpCollisionFilter.h>
#include <Physics/Collide/Filter/List/hkpCollisionFilterList.h>
#include <Physics/Collide/Filter/hkpConvexListFilter.h>
#include <Physics/Collide/Filter/DefaultConvexList/hkpDefaultConvexListFilter.h>
#include <Physics/Collide/Filter/Group/hkpGroupFilter.h>
#include <Physics/Collide/Filter/Group/hkpGroupFilterSetup.h>
#include <Physics/Collide/Filter/Null/hkpNullCollisionFilter.h>
#include <Physics/Collide/Filter/hkpRayCollidableFilter.h>
#include <Physics/Collide/Filter/hkpShapeCollectionFilter.h>
#include <Physics/Collide/Util/ShapeCutter/hkpShapeCutterUtil.h>
#pragma managed

namespace Havok4Xna {
	ref class HkAabb;
	namespace Physics {
		namespace Collide {
			ref class HkpWorldRayCastInput;
			ref class HkpCollidable;
		}
	}
}
using namespace Havok4Xna;
using namespace Havok4Xna::Physics::Collide;

namespace Havok4Xna {
	ref class HkAabb;

	namespace Physics {
		namespace Collide {	
#define DECLARE_INTERFACE_HkpCollidableCollidableFilter(type)\
			type bool IsCollisionEnabled(HkpCollidable ^collidableA, HkpCollidable ^collidableB);
#define IMPLEMENT_INTERFACE_HkpCollidableCollidableFilter(implementingClass)\
			bool implementingClass::IsCollisionEnabled(HkpCollidable ^collidableA, HkpCollidable ^collidableB) {\
				return _this()->isCollisionEnabled(collidableA->_ref(), collidableB->_ref());\
			}

			public interface class HkpCollidableCollidableFilter : public INativeReference {
				DECLARE_INTERFACE_HkpCollidableCollidableFilter();
			};

#define DECLARE_INTERFACE_HkpRayCollidableFilter(type)\
			type bool IsCollisionEnabled(HkpWorldRayCastInput ^collidableA, HkpCollidable ^collidableB);
#define IMPLEMENT_INTERFACE_HkpRayCollidableFilter(implementingClass)\
			bool implementingClass::IsCollisionEnabled(HkpWorldRayCastInput ^collidableA, HkpCollidable ^collidableB) {\
				return _this()->isCollisionEnabled(collidableA->_ref(), collidableB->_ref());\
			}

			public interface class HkpRayCollidableFilter : public INativeReference {
				DECLARE_INTERFACE_HkpRayCollidableFilter();
			};

#define DECLARE_INTERFACE_HkpShapeCollectionFilter(type)\
			type bool IsCollisionEnabled(HkpCollisionInput ^input, HkpCdBody ^bodyA,\
				HkpCdBody ^collectionBodyB, HkpShapeContainer ^containerShapeB, hkpShapeKey keyB);\
			type bool IsCollisionEnabled(HkpCollisionInput ^input, HkpCdBody ^collectionBodyA,\
				HkpCdBody ^collectionBodyB, HkpShapeContainer ^containerShapeA, HkpShapeContainer ^containerShapeB,\
				hkpShapeKey keyB);\
			type int NumShapeKeyHitsLimitBreached(HkpCollisionInput ^input, HkpCdBody ^bodyA, HkpCdBody ^bodyB,\
				HkpBvTreeShape ^bvTreeShapeB, HkAabb ^aabb, hkpShapeKey shapeKeysInOut, int shapeKeysCapacity);
#define IMPLEMENT_INTERFACE_HkpShapeCollectionFilter(implementingClass)\
			bool IsCollisionEnabled(HkpCollisionInput ^input, HkpCdBody ^bodyA,\
				HkpCdBody ^collectionBodyB, HkpShapeContainer ^containerShapeB, hkpShapeKey keyB);\
			bool IsCollisionEnabled(HkpCollisionInput ^input, HkpCdBody ^collectionBodyA,\
				HkpCdBody ^collectionBodyB, HkpShapeContainer ^containerShapeA, HkpShapeContainer ^containerShapeB,\
				hkpShapeKey keyB);\
			int NumShapeKeyHitsLimitBreached(HkpCollisionInput ^input, HkpCdBody ^bodyA, HkpCdBody ^bodyB,\
				HkpBvTreeShape ^bvTreeShapeB, HkAabb ^aabb, hkpShapeKey shapeKeysInOut, int shapeKeysCapacity);

			public interface class HkpShapeCollectionFilter : public INativeReference {
				DECLARE_INTERFACE_HkpShapeCollectionFilter();
			};

			public ref class HkpCollisionFilter : public INativeReference
				/*: public HkpCollidableCollidableFilter, HkpShapeCollectionFilter, HkpRayShapeCollectionFilter, HkpRayCollidableFilter*/ {
			public:
				enum class HkpFilterType : int {
					Unknown = hkpCollisionFilter::HK_FILTER_UNKNOWN,
					Null = hkpCollisionFilter::HK_FILTER_NULL,
					Group = hkpCollisionFilter::HK_FILTER_GROUP,
					List = hkpCollisionFilter::HK_FILTER_LIST,
					Custom = hkpCollisionFilter::HK_FILTER_CUSTOM,
					Pair = hkpCollisionFilter::HK_FILTER_PAIR,
					Constraint = hkpCollisionFilter::HK_FILTER_CONSTRAINT
				};

				/*DECLARE_INTERFACE_HkpCollidableCollidableFilter(virtual);
				DECLARE_INTERFACE_HkpShapeCollectionFilter(virtual);
				DECLARE_INTERFACE_HkpRayShapeCollectionFilter(virtual);
				DECLARE_INTERFACE_HkpRayCollidableFilter(virtual);*/

			internal:
				HK_CLASS_INTERNALS(HkpCollisionFilter, hkpCollisionFilter)
			};

			public ref class HkpCollisionFilterList : public HkpCollisionFilter {
			internal:
				HK_DERIVED_CLASS_INTERNALS(HkpCollisionFilterList, hkpCollisionFilterList, HkpCollisionFilter)
			};

#define DECLARE_INTERFACE_HkpConvexListFilter(type) \
			type HkpConvexListFilter::ConvexListCollisionType GetConvexListCollisionType(\
					HkpCdBody ^convexListBody, HkpCdBody ^otherBody, HkpCollisionInput ^input);
#define IMPLEMENT_INTERFACE_HkpConvexListFilter(implementingClass)\
			HkpConvexListFilter::ConvexListCollisionType implementingClass::GetConvexListCollisionType(\
			HkpCdBody ^convexListBody, HkpCdBody ^otherBody, HkpCollisionInput ^input) {\
				return (HkpConvexListFilter::ConvexListCollisionType) _this()->getConvexListCollisionType(convexListBody->_ref(),\
					otherBody->_ref(), input->_ref());\
			}

			public interface class HkpConvexListFilter : public INativeReference {
				enum class ConvexListCollisionType : int {
					TreatConvexListAsNormal = hkpConvexListFilter::TREAT_CONVEX_LIST_AS_NORMAL,
					TreatConvexListAsList = hkpConvexListFilter::TREAT_CONVEX_LIST_AS_LIST,
					TreatConvexListAsConvex = hkpConvexListFilter::TREAT_CONVEX_LIST_AS_CONVEX
				};
				DECLARE_INTERFACE_HkpConvexListFilter();
			};

			public ref class HkpDefaultConvexListFilter : public HkpConvexListFilter {
			public:
				HkpDefaultConvexListFilter();
				DECLARE_INTERFACE_HkpConvexListFilter(virtual);

			internal:
				HK_CLASS_INTERNALS(HkpDefaultConvexListFilter, hkpDefaultConvexListFilter)
			};

			public ref class HkpGroupFilter : public HkpCollisionFilter {
			internal:
				HK_DERIVED_CLASS_INTERNALS(HkpGroupFilter, hkpGroupFilter, HkpCollisionFilter)
			};

			public ref class HkpGroupFilterSetup : public INativeReference {
			internal:
				HK_CLASS_INTERNALS(HkpGroupFilterSetup, hkpGroupFilterSetup)
			};

			public ref class HkpNullCollisionFilter : public HkpCollisionFilter {
			internal:
				HK_DERIVED_CLASS_INTERNALS(HkpNullCollisionFilter, hkpNullCollisionFilter, HkpCollisionFilter)
			};

			public ref class HkpShapeConnectedCalculator : public INativeReference {
			internal:
				HK_CLASS_INTERNALS(HkpShapeConnectedCalculator, hkpShapeConnectedCalculator)
			};

			public ref class HkpShapeCutterUtil : public INativeReference {
			internal:
				HK_CLASS_INTERNALS(HkpShapeCutterUtil, hkpShapeCutterUtil)
			};
		}
	}
}
